<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>title</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <fieldset class="table-search-fieldset" >
            <legend>聊天日志</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="" lay-filter="table-search" id="search">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">选择区服:</label>
                            <div class="layui-input-inline">
                                <select name="gameArea" class="layui-select">
                                    <option v-for="(item,index) in services" :value="item.server_id" :selected="index==0">{{item.name}}</option>
                                </select>
                            </div>
                        </div>
                       <!-- <div class="layui-inline">
                            <label class="layui-form-label">账号ID:</label>
                            <div class="layui-input-inline">
                               <input type="text" name="memId" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">角色ID:</label>
                            <div class="layui-input-inline">
                                <input type="text" name="memId" class="layui-input">
                            </div>
                        </div>-->
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary"  lay-submit lay-filter="data-search-btn">
                                <i class="layui-icon"></i> 搜 索</button>
                            <button type="submit1" class="layui-btn layui-btn-primary"  lay-submit lay-filter="data-search-btn1">
                                <i class="layui-icon"></i>合并搜索</button>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>
        <script type="text/html" id="topToolBar">
            <div class="layui-btn-container">
            </div>
        </script>
        <table class="layui-hide" id="current-table" lay-filter="current-table"></table>
        <script type="text/html" id="currentTableBar">
        </script>
    </div>
</div>
<script src="/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="/js/common.js?v=5" charset="utf-8"></script>
<script>
    new Vue({
        el:"#search",
        data:{
            services: JSON.parse(localStorage.getItem('services')),
        },
        created(){

        },
        updated(){

        },
        mounted(){
            layui.use(['form', 'table'], function () {
                var $ = layui.jquery,
                    form = layui.form,
                    table = layui.table;

                table.render({
                    elem: '#current-table',
                    url: "/admin/interface/pageint",
                    where:form.val('table-search'),
                    toolbar: '#topToolBar',
                    defaultToolbar: ['filter'],
                    cols: [[
                        {type: "checkbox", width: 50},
                        {field: "logTime", title: "时间戳",templet:function (row) {
                                return getYMDHMS(row.logTime)
                            }},
                        {field: "memId", title: "账号ID"},
                        {field: "roleId", title: "角色ID"},
                        {field: "memberName", title: "账号",templet:function(row){
                                return row.member?row.member.username:'';
                            }},
                        {field: "nick", title: "角色昵称",templet:function(row){
                                return row.role?row.role.nick:'';
                            }},
                        {field: "chat_type", title: "频道",templet:function(row){
                                var values = [{"value":1,"title":"世界"},{"value":2,"title":"氏族"},
                                    {"value":3,"title":"队伍"},{"value":4,"title":"私聊"},{"value":5,"title":"传闻"},
                                    {"value":6,"title":"附近"},{"value":7,"title":"大喇叭"}];
                                var value = row.chat_type;
                                for(var k in values){
                                    if(value === values[k].value ){
                                        return values[k].title
                                    }
                                }
                                return row.chat_type;
                            }},
                        {field: "chat_content", title: "聊天内容"},
                        {field: "other_role_id", title: "收信角色ID"},
                        {field: "other_role_nick", title: "收信角色昵称"},
                        //{title: '操作', minWidth: 150, toolbar: '#currentTableBar', align: "center"}
                    ]],
                    limits: [10, 15, 20, 25, 50, 100],
                    limit: 15,
                    page: true,
                    skin: 'line'
                });

                form.on('submit(data-search-btn)', function (data) {
                    var searchData = data.field;
                    //执行搜索重载
                    table.reload('current-table', {
                        url: "/admin/interface/hbpageint",
                        page: { curr : 1 }
                        , where:searchData
                    }, 'data');
                    return false;
                });
                //合并搜索
                form.on('submit(data-search-btn)', function (data) {
                    var searchData = data.field;
                    //执行搜索重载
                    table.reload('current-table', {
                        page: { curr : 1 }
                        , where:searchData
                    }, 'data');
                    return false;
                });
                table.on('toolbar(current-table)', function (obj) {
                    if (obj.event === 'insert') {
                        layer.open({
                            title: "聊天日志-添加",
                            type: 2,
                            shade: 0.2,
                            maxmin:true,
                            shadeClose: true,
                            area: ['700px', '500px'],
                            content: 'form.html',
                        });
                    } else {
                        console.log(1)
                    }
                });

                table.on('tool(current-table)', function (obj) {
                    if (obj.event === 'update') {
                        layer.open({
                            title: "聊天日志-编辑",
                            type: 2,
                            shade: 0.2,
                            maxmin:true,
                            shadeClose: true,
                            area: ['700px', '500px'],
                            content: 'form.html?id='+obj.data.id,
                        });
                        return false;
                    } else if (obj.event === 'delete') {
                        var delPop = layer.confirm('确定要删除吗?',{title:"提示",icon:3},function(){
                            $.post("/admin/logRoleChat/"+obj.data.id,{_method:'delete'},function (res) {
                                if (res.code === 0){
                                    layer.msg('删除成功',{icon:1,time:500},function(){
                                        table.reload('current-table');
                                    })
                                    table.reload()
                                    layer.close(delPop)
                                } else {
                                    layer.msg(res.msg,{icon:2})
                                }
                            });
                        })
                    }
                });
            });
        }
    })

</script>
</body>
</html>
